using TestCases.CompareAssert.Core.Interfaces;

namespace TestCases.CompareAssert.Core.Builders
{
    public static class ResultBuilderUtils
    {
        
        public static IResultBuilder ForStatus(this IResultBuilder builder, CompareStatus status, string message)
        {
            return (builder.GetStatus() == status) ? builder.Message(message) : builder;
        }

        public static IResultBuilder WithStatus(this IResultBuilder builder, CompareStatus status, object args)
        {
            return (builder.GetStatus() == status) ? builder.With(args) : builder;
        }

        public static IResultBuilder ForEquals(this IResultBuilder builder, string message)
        {
            return ForStatus(builder, CompareStatus.Equals, message);
        }

        public static IResultBuilder ForNotEquals(this IResultBuilder builder, string message)
        {
            return ForStatus(builder, CompareStatus.NotEquals, message);
        }

        public static IResultBuilder ForNotApplicable(this IResultBuilder builder, string message)
        {
            return ForStatus(builder, CompareStatus.NotApplicable, message);
        }

        public static IResultBuilder WithEquals(this IResultBuilder builder, object args)
        {
            return WithStatus(builder, CompareStatus.Equals, args);
        }

        public static IResultBuilder WithNotEquals(this IResultBuilder builder, object args)
        {
            return WithStatus(builder, CompareStatus.NotEquals, args);
        }

        public static IResultBuilder WithNotApplicable(this IResultBuilder builder, object args)
        {
            return WithStatus(builder, CompareStatus.NotApplicable, args);
        }


        public static IResultBuilder TryChangeStatus(this IResultBuilder builder, CompareStatus fromStatus, CompareStatus toStatus)
        {
            return (builder.GetStatus() == fromStatus)
                ? builder.Status(toStatus)
                : builder;
        }
    }
}